//
//  ViewController.m
//  Ui_Tel
//
//  Created by 江山 on 15/11/23.
//  Copyright © 2015年 hi. All rights reserved.
//

#import "ViewController.h"
#import "inputViewController.h"
@interface ViewController ()
{
    NSArray * name;
    NSArray * tels;
    NSIndexPath * curIndexPath;
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    name = @[
             @"赵日天",
             @"王诛魔",
             @"刘斩仙"
             ];
    
    tels = @[
            @"1024",
            @"1024",
            @"1024"
            ];
    
    
    self.title = @"你怕了吗？";
    NSUserDefaults * def = [NSUserDefaults standardUserDefaults];
    [def setObject:name forKey:@"name"];
    [def setObject:tels forKey:@"tel"];
    [def synchronize];
    
    name = [def objectForKey:@"name"];
    tels = [def objectForKey:@"tel"];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return name.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    cell.textLabel.text = name[indexPath.row];
    cell.detailTextLabel.text = tels[indexPath.row];
    

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    inputViewController *con = [[inputViewController alloc] initWithStyle:UITableViewStyleGrouped];
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    con.tel = cell.detailTextLabel.text;
    [self.navigationController pushViewController:con animated:YES];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
